<%@page import="java.lang.management.ManagementFactory"%>
<%@page import="java.lang.management.ThreadMXBean"%>
<%@page import="java.lang.management.ThreadInfo"%>
<table border = "1">




<%
ThreadMXBean tm = ManagementFactory.getThreadMXBean();
tm.setThreadContentionMonitoringEnabled(true);
long [] tid = tm.getAllThreadIds();
ThreadInfo [] tia = tm.getThreadInfo(tid, Integer.MAX_VALUE);

long [][] threadArray = new long[tia.length][2];

for (int i = 0; i < tia.length; i++) {
long threadId = tia[i].getThreadId();
String name = tia[i].getThreadName();
String lockName = tia[i].getLockName();
String lockOwenerName = tia[i].getLockOwnerName();
StackTraceElement[] stack = tia[i].getStackTrace();
long cpuTime = tm.getThreadCpuTime(tia[i].getThreadId())/(1000*1000*1000);
%>
<tr>
	<td nowrap="nowrap">Thread ID:<%=threadId%></td>
	<Td nowrap="nowrap">Thread Name: <%=name%></Td>
	<Td nowrap="nowrap">Thread State: <%=tia[i].getThreadState().name()%></Td>
	<Td nowrap="nowrap">Thread Lock Name: <%=lockName%></Td>
	<Td nowrap="nowrap">Thread Lock Owner Name: <%=lockOwenerName%></Td>
	<Td nowrap="nowrap">Thread CPU Time: <%=cpuTime%>  </Td>
	<Td nowrap="nowrap">StackTrace: 
	<%for(int j =0;j<stack.length;j++){
	%>
	 <Br><%=stack[j].getFileName() %>
	 <Br><%=stack[j].getClassName() %>
	 <Br><%=stack[j].getMethodName() %>
	 <Br><%=stack[j].getLineNumber() %>
	 
	<%
	} %>
	 </Td>
</tr>
<%
}
%>
</table>

